home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / machack / Hacks96 / InternetChooser.sit / Internet Chooser / Sample LDEFs 2.0 / (Sys 7) Icon LDEF / Tester Src / main.c < prev    next >
C/C++ Source or Header  |  1993-10-24  |  3KB  |  128 lines

  1. // File "main.c"
  2.  
  3. #include <GestaltEqu.h>
  4.  
  5. #include "main.h"
  6. #include "List.h"
  7. #include "Windows.h"
  8.  
  9. // * **************************************************************************** * //
  10. // Global Declarations
  11.  
  12. short hasColorQD;
  13. WindowPtr gWindow;
  14. EventRecord gEvent;
  15. ListHandle gList;
  16.  
  17. // * **************************************************************************** * //
  18. // * **************************************************************************** * //
  19.  
  20. void DoInit() {
  21.     long response;
  22.     Rect destRect;
  23.     
  24.     InitGraf(&thePort);
  25.     InitFonts();
  26.     InitWindows();
  27.     InitMenus();
  28.     TEInit();
  29.     InitDialogs(0);
  30.     
  31.     hasColorQD = (Gestalt(gestaltQuickdrawFeatures, &response) ||
  32.         ((response & (1 << gestaltHasColor)) == 0)) ? 0 : -1;
  33.     
  34.     SetRect(&destRect, 40, 40, 200, 250);
  35.     gWindow = (hasColorQD) ?
  36.             NewCWindow(0, &destRect, "\pList Tester", 0, documentProc, (WindowPtr) -1, -1, 0) :
  37.             NewWindow(0, &destRect, "\pList Tester", 0, documentProc, (WindowPtr) -1, -1, 0);
  38.     CreateList();
  39.     ShowWindow(gWindow);
  40.     }
  41.  
  42. // * **************************************************************************** * //
  43. // * **************************************************************************** * //
  44.  
  45. void DoLoop() {
  46.     short running;
  47.     long sizeVH;
  48.     Rect sizeRect;
  49.     GrafPtr savePort;
  50.     WindowPtr whichWin;
  51.     EventRecord theEvent;
  52.     
  53.     running = -1;
  54.     while(running) {
  55.         if (WaitNextEvent(everyEvent, &theEvent, 60, 0)) {
  56.             switch(theEvent.what) {
  57.                 case nullEvent:
  58.                     break;
  59.                 case mouseDown:
  60.                     switch(FindWindow(theEvent.where, &whichWin)) {
  61.                         case inMenuBar: SysBeep(7); break;
  62.                         case inContent: 
  63.                             GetPort(&savePort);
  64.                             SetPort(gWindow);
  65.                             GlobalToLocal(&theEvent.where);
  66.                             LClick(theEvent.where, theEvent.modifiers, gList);
  67.                             SetPort(savePort);
  68.                             break;
  69.                         case inDrag:
  70.                             DragWindow(gWindow, theEvent.where, &screenBits.bounds);
  71.                             break;
  72.                         case inGrow:
  73.                             sizeRect = screenBits.bounds;
  74.                             sizeRect.left = 40;
  75.                             sizeRect.top = 60;
  76.                             sizeVH = GrowWindow(gWindow, theEvent.where, &sizeRect);
  77.                             if (sizeVH) {
  78.                                 SizeWindow(gWindow, LoWord(sizeVH), HiWord(sizeVH), -1);
  79.                                 LSize(LoWord(sizeVH)-15, HiWord(sizeVH)-15, gList);
  80.                                 GetPort(&savePort);
  81.                                 SetPort(gWindow);
  82.                                 InvalRect(&gWindow->portRect);
  83.                                 SetPort(savePort);
  84.                                 }
  85.                             break;
  86.                         case inGoAway:
  87.                             if (TrackGoAway(gWindow, theEvent.where)) running = 0;
  88.                             break;
  89.                         default: break;
  90.                         }
  91.                     break;
  92.                 case keyDown:
  93.                 case autoKey:
  94.                     if (((theEvent.message & keyCodeMask) >> 8 == 0x0C) && 
  95.                             (theEvent.modifiers & cmdKey)) running = 0;
  96.                     break;
  97.                 case updateEvt:
  98.                     DoUpdate();
  99.                     break;
  100.                 case activateEvt:
  101.                     DoActivate(theEvent.modifiers & activeFlag);
  102.                     break;
  103.                 default:
  104.                     break;
  105.                 }
  106.             SetCursor(&arrow);
  107.             }
  108.         }
  109.     }
  110.  
  111. // * **************************************************************************** * //
  112. // * **************************************************************************** * //
  113.  
  114. void DoClose() {
  115.     DisposeList();
  116.     DisposeWindow(gWindow);
  117.     }
  118.  
  119. // * **************************************************************************** * //
  120. // * **************************************************************************** * //
  121.  
  122. void main() {
  123.  
  124.     DoInit();
  125.     DoLoop();
  126.     DoClose();
  127.     }
  128.